using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InGameTutorBlockPanel : MonoBehaviour
{
	public UILabel textLabel;

	public GameObject labelObj;

	public GameObject BlockBG;

	private Dictionary<GameObject, Transform> perents = new Dictionary<GameObject, Transform>();

	public bool ShowingText
	{
		get
		{
			return labelObj.activeSelf;
		}
	}

	private void Awake()
	{
		SetText(string.Empty, false);
	}

	public void SetText(string text, bool val)
	{
		labelObj.SetActive(val);
		textLabel.text = text;
	}

	public string GetText()
	{
		return textLabel.text;
	}

	public void EnableBlock(bool val)
	{
		BlockBG.SetActive(val);
	}

	public void UnblockUIElement(GameObject obj, bool val, bool onAllObject = true)
	{
		if (val)
		{
			if (!perents.ContainsKey(obj))
			{
				perents.Add(obj, obj.transform.parent);
				obj.transform.parent = base.transform;
				StartCoroutine(UpdateDepthInBlockPanel(obj.GetComponentsInChildren<UIWidget>(true), val, onAllObject));
			}
		}
		else if (perents.ContainsKey(obj))
		{
			obj.transform.parent = perents[obj];
			perents.Remove(obj);
			StartCoroutine(UpdateDepthInBlockPanel(obj.GetComponentsInChildren<UIWidget>(true), val, onAllObject));
		}
	}

	private IEnumerator UpdateDepthInBlockPanel(UIWidget[] sprites, bool val, bool onAllObject = true)
	{
		foreach (UIWidget sprite2 in sprites)
		{
			if (val)
			{
				sprite2.depth += Mathf.Abs(BlockBG.GetComponent<UIWidget>().depth) * 2 + 1;
			}
			else
			{
				sprite2.depth -= Mathf.Abs(BlockBG.GetComponent<UIWidget>().depth * 2) - 1;
			}
			if (onAllObject)
			{
				sprite2.enabled = false;
			}
		}
		yield return null;
		foreach (UIWidget sprite in sprites)
		{
			if (sprite != null && onAllObject)
			{
				sprite.enabled = true;
			}
		}
	}

	public void Depth(int depth)
	{
		GetComponent<UIPanel>().depth = depth;
	}
}
